Skip to content

Conversation

@vogella
Copy link
Contributor

@vogella vogella commented Nov 11, 2025

Summary

Fixes the random failures in DynamicTest.testDynamicRegistry by replacing the plain boolean array with AtomicBoolean instances for proper thread-safe visibility across listener callbacks.

Root Cause

The test was failing randomly with "Activity Listener not called" or "Category Listener not called" errors because:

  • The test uses a plain boolean[] to track listener invocations
  • Extension registry listeners may be invoked on different threads
  • Without proper synchronization (volatile/atomic), changes to the array made by listener threads may not be visible to the test thread
  • This causes DisplayHelper.waitForCondition() to timeout even when listeners were actually called

Changes

  • Replace boolean[] registryChanged with two AtomicBoolean instances (activityChanged and categoryChanged)
  • Update listeners to use .set(true) instead of array assignment
  • Update condition checks and assertions to use .get() instead of array access
  • Add import for java.util.concurrent.atomic.AtomicBoolean

Test Plan

  • Ran the test 5 times consecutively - all passed ✅
  • The fix ensures proper memory barriers between listener threads and test thread

Related Issues

Fixes #2458

🤖 Generated with Claude Code

vogella and others added 2 commits November 11, 2025 07:23
The testEnabledWhenHover test was failing randomly when trying to retrieve
the hover shell for the second part of the test.

Root cause:
- The test has two parts: first with EnabledPropertyTester.setEnabled(true),
  then with setEnabled(false)
- After the first hover is shown and checked, cleanFileAndEditor() is called
- However, the hover shell from the first part may not be fully disposed
  when the second editor is opened and the second hover is triggered
- This causes getHoverShell() to timeout waiting for the new hover shell

Fix:
- Capture a reference to the first hover shell before calling cleanFileAndEditor()
- After cleanFileAndEditor(), explicitly wait for the first shell to be disposed
  using DisplayHelper.waitForCondition() with a 3000ms timeout
- This ensures the hover state is fully reset before the second part begins

This approach follows the pattern used in other recent flaky test fixes in
this repository (e.g., ProgressContantsTest, ProgressViewTests) which use
condition-based waiting to ensure proper cleanup between test phases.

Fixes eclipse-platform#926

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
The testDynamicRegistry test was failing randomly with
"Activity Listener not called" or "Category Listener not called" errors.

Root cause:
- The test uses a plain boolean array to track listener invocations
- Extension registry listeners may be invoked on different threads
- Without proper synchronization (volatile/atomic), changes to the array
  made by listener threads may not be visible to the test thread
- This causes DisplayHelper.waitForCondition() to timeout even when
  listeners were actually called

Fix:
- Replace boolean[] with AtomicBoolean instances for thread-safe visibility
- Use activityChanged.set(true) and categoryChanged.set(true) in listeners
- Use activityChanged.get() and categoryChanged.get() in assertions
- AtomicBoolean provides proper memory barriers ensuring cross-thread visibility

This approach ensures proper synchronization between the listener callback
threads and the test thread, eliminating the race condition that caused
random test failures.

Fixes eclipse-platform#2458

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@github-actions
Copy link
Contributor

Test Results

 3 018 files  ±0   3 018 suites  ±0   2h 11m 16s ⏱️ + 3m 38s
 8 234 tests ±0   7 985 ✅ ±0  249 💤 ±0  0 ❌ ±0 
23 622 runs  ±0  22 828 ✅ ±0  794 💤 ±0  0 ❌ ±0 

Results for commit 4f377ac. ± Comparison against base commit 02dabfc.

@vogella vogella marked this pull request as ready for review November 11, 2025 07:45
@vogella
Copy link
Contributor Author

vogella commented Nov 11, 2025

@fedejeanne WDYT?

@vogella vogella merged commit dd5d18e into eclipse-platform:master Nov 11, 2025
18 checks passed
@vogella vogella deleted the fix-issue-2458-flaky-dynamic-test branch November 11, 2025 14:30
@fedejeanne
Copy link
Member

Sorry for the late reply. The changes look OK. Based on the description of the issue, this additional wait shouldn't be necessary (or at least, I don't see why it is necessary in the description):

DisplayHelper.waitForCondition(display, 3000, () -> firstShell.isDisposed());

But since that operation doesn't slow down the test if the shell is disposed, I'd say it's safe to use 👍

Thank you for fixing the flaky tests, @vogella ! 🚀 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DynamicTest.testDynamicRegistry fails randomly

2 participants